/**
*      author: Y_Yao
*      created: 2024-12-14 17:45:25
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 1e3 + 7;
string s;
int dp[N][N];

void solve()
{
    cin >> s;
    int n = s.size();
    s = ' ' + s;

    for(int i = n;i >= 1;i--)
    {
        for(int j = i;j <= n;j++)
        {
            if(s[i] == s[j])
            {
                dp[i][j] = dp[i + 1][j - 1];
            }
            else
            {
                dp[i][j] = min(dp[i+1][j-1] + 2,min(dp[i][j-1] + 1,dp[i+1][j] + 1));
            }
        }
    }

    // for(int i = 1;i <= n;i++)
    // {
    //     for(int j = 1;j <= n;j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << dp[1][n] << endl;;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}